/**
 * 
 */
package com.dsteiner.widgets.client.model;

import java.beans.PropertyChangeListener;

import com.dsteiner.widgets.client.PropertyChangeCollection;

public class PaginationModel {
	private PropertyChangeCollection propertyChangeSupport = new PropertyChangeCollection(
			this);

	public void addPropertyChangeListener(String propertyName,
			PropertyChangeListener listener) {
		propertyChangeSupport.registerPropertyChangeListener(propertyName,
				listener);
	}
	
	private int count = 0;

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		int oldCount = this.count;
		this.count = count;
		propertyChangeSupport.firePropertyChange("count", oldCount, count);
	}
	
	private int page = 0;

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		int oldPage = this.page;
		this.page = page;
		propertyChangeSupport.firePropertyChange("page", oldPage, page);
	}
	
	private int itemsPerPage = 10;

	public int getItemsPerPage() {
		return itemsPerPage;
	}

	public void setItemsPerPage(int itemsPerPage) {
		int oldItemsPerPage = this.itemsPerPage;
		this.itemsPerPage = itemsPerPage;
		propertyChangeSupport.firePropertyChange("itemsPerPage", oldItemsPerPage, itemsPerPage);
	}

	public int getOffset() {
		return page * itemsPerPage;
	}
}